package com.sinoyd.itszyw;

import android.app.Application;
import android.util.Log;

import com.sinoyd.itszyw.Model.VersionUpdate;
import com.sinoyd.itszyw.Util.CrashHandlerUtils;

import org.xutils.DbManager;
import org.xutils.db.table.TableEntity;
import org.xutils.x;

import java.util.ArrayList;

/**
 * @author: Sinoyd  --------->作者
 * @description: --------->描述
 * @projectName: ITSZYW  ---------> 项目名称
 * @date: 2017-03-09 ---------> 创建日期
 * @time: 09:01       ---------> 创建时间
 */
public class MyApplication extends Application {

    public static DbManager db;
    public static String loginId;
    public static String loginName;
    public static String logRrowGuid;
    public static ArrayList<String> imageListUrls = new ArrayList<>();


    public static String WebService = "http://222.92.146.58:8700/WebServiceITOMMP/WebServiceITOMMP.asmx/";
//
//    public static String WebService = "http://192.168.90.188/WebServiceITOMMP/WebServiceITOMMP.asmx/";

    /**
     * 登录
     */
    public static String GetLoginInfo = WebService + "GetLoginInfo";
    /**
     * 获取获取部门信息
     */
    public static String GetDepartment = WebService + "GetDepartment";
    /**
     * 获取任务下发人
     */
    public static String GetAllUser = WebService + "GetAllUser";
    /**
     * 获取任务下发人
     */
    public static String GetReleaseUser = WebService + "GetReleaseUser";
    /**
     * 维护任务
     */
    public static String GetMaintainTasks = WebService + "GetMaintainTasks";
    /**
     * 任务种类
     */
    public static String GetTaskVariety = WebService + "GetTaskVariety";
    /**
     * 上传任务
     */
    public static String postMaintainTasks = WebService + "postMaintainTasks";
    /**
     * 上传创建的任务
     */
    public static String createMaintainTask = WebService + "CreateMaintainTask";
    /**
     * 获取例行巡检
     */
    public static String GetInspection = WebService + "GetInspection";
    /**
     * 上传例行巡检
     */
    public static String postRoutineInspection = WebService + "postRoutineInspection";

    /**
     * 版本更新
     */
    public static String GetVersion = WebService + "GetVersion";

    public static VersionUpdate VERSION_DATA;
    public static String versionName;
    public static double versionCode;

    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);
        CrashHandlerUtils.getInstance().init(this);


        /**
         * 初始化DaoConfig配置
         */
        DbManager.DaoConfig daoConfig = new DbManager.DaoConfig()
                //设置数据库名，默认xutils.db
                .setDbName("ITYW.db")
                //设置数据库路径，默认存储在app的私有目录
//                .setDbDir(new File("/mnt/sdcard/"))
                //设置数据库的版本号
                .setDbVersion(2)
                //设置数据库打开的监听
                .setDbOpenListener(new DbManager.DbOpenListener() {
                    @Override
                    public void onDbOpened(DbManager db) {
                        //开启数据库支持多线程操作，提升性能，对写入加速提升巨大
                        db.getDatabase().enableWriteAheadLogging();
                    }
                })
                //设置数据库更新的监听
                .setDbUpgradeListener(new DbManager.DbUpgradeListener() {
                    @Override
                    public void onUpgrade(DbManager db, int oldVersion, int newVersion) {
                    }
                })
                //设置表创建的监听
                .setTableCreateListener(new DbManager.TableCreateListener() {
                    @Override
                    public void onTableCreated(DbManager db, TableEntity<?> table) {
                        Log.i("JAVA", "onTableCreated：" + table.getName());
                    }
                });
        //设置是否允许事务，默认true
        //.setAllowTransaction(true)

        db = x.getDb(daoConfig);

    }
}
